<?php 
defined('IN_TS') or die('Access Denied.');

switch($ts){
	case "topic":
	
		$userid = intval($_GET['userid']);
		$page = intval($_GET['page']);
		
		$myGroup = $new['group']->findAll('group_users',array(
			'userid'=>$userid,
		));
		
		if($myGroup){
			
			$lstart = $page*30-30;
		
			foreach($myGroup as $item){
				$arrGroup[] = $item['groupid'];
			}
			
			$strGroup = implode(',',$arrGroup);
			
			$arrTopics = $db->fetch_all_assoc("select * from ".dbprefix."group_topics where groupid in ($strGroup) and `isshow`='0'  and `isaudit`='0'  order by uptime desc limit $lstart,30");
			foreach($arrTopics as $key=>$item){
				$arrTopic[] = $item;
				$arrTopic[$key]['title'] = htmlspecialchars($item['title']);
				$arrTopic[$key]['user'] = aac('user')->getOneUser($item['userid']);
				$arrTopic[$key]['group'] = aac('group')->getOneGroup($item['groupid']);
			}
			
		}	

		include template('ajax_topic');
		break;
}